﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Howork
{
    public partial class NewWork : System.Web.UI.Page
    {
        //private WorkType type = WorkType.gwlzwxsp;
        public String workURL;

        protected void Page_Load(object sender, EventArgs e)
        {
            
            if(Session["login"] == "login")  //已登录
            {

                //setButtons();


                String typestr = Request.QueryString["WorkType"];
                if (typestr == "gwlzwxsp")
                {
                    Session["work_type"] = WorkType.gwlzwxsp;
                }
                else if (typestr == "gwlzxsp")
                {
                    Session["work_type"] = WorkType.gwlzxsp;
                }
                else if (typestr == "shebeishiyongshenqing")
                {
                    Session["work_type"] = WorkType.shebeishiyongshenqing;
                }
                else if (typestr == "huiyishenqing")
                {
                    Session["work_type"] = WorkType.huiyishenqing;
                }
                else if (typestr == "qingjia")
                {
                    Session["work_type"] = WorkType.qingjia;
                }
                else if (typestr == "tongzhiyuhuirenyuan")
                {
                    Session["work_type"] = WorkType.tongzhiyuhuirenyuan;
                }



                setURL();

                
                
            }
        }

        //private void setButtons()
        //{
        //    if (((String)Session["station_id"]).Length == 0)
        //    {
        //        shebeishiyongshenqing.Visible = false;
        //        huiyishenqing.Visible = false;
        //        tongzhiyuhuirenyuan.Visible = false;
        //        qingjia.Visible = false;
        //        gwlzwxsp.Visible = false;
        //        gwlzxsp.Visible = false;
        //        return;
        //    }

        //    //除了总经理以外的所有人可以申请使用设备、请假、公文流转（需审批）
        //    if (String.Compare(((String)Session["station_id"]), "01") == 0)
        //    //if(Session["station_id"] == "01")
        //    {
        //        shebeishiyongshenqing.Visible = false;
        //        qingjia.Visible = false;
        //        gwlzxsp.Visible = false;
        //    }
        //    //普通员工不可以申请会议
        //    if (String.Compare(((String)Session["station_grade"]), "3") == 0)
        //    //if(Session["station_grade"] == "3")
        //    {
        //        huiyishenqing.Visible = false;
        //    }
        //    //服务部员工可以通知与会人员
        //    if (String.Compare(((String)Session["department_id"]), "0102") != 0)
        //    //if(Session["department_id"] != "0102")
        //    {
        //        tongzhiyuhuirenyuan.Visible = false;
        //    }
        //}

        private void setURL()
        {

            //013：设备使用申请
            //014：会议申请
            //016：通知与会人员
            //017：请假（基层）
            //018：请假（中层）
            //019：公文流转（无需审批）
            //020：公文流转（基层）
            //021：公文流转（中层）
            switch ((WorkType)(Session["work_type"]))
            {
                case WorkType.gwlzwxsp:
                    {
                        Msg.Text = "公文流转（无需审批）";
                        workURL = WorkFlowURL.WorkURL("019");
                    }
                    break;
                case WorkType.gwlzxsp:
                    {
                        Msg.Text = "公文流转（需审批）";
                        if (String.Compare(((String)Session["station_grade"]), "3") == 0) //基层
                        {
                            workURL = WorkFlowURL.WorkURL("020");
                        }
                        else if (String.Compare(((String)Session["station_grade"]), "2") == 0) //中层
                        {
                            workURL = WorkFlowURL.WorkURL("021");
                        }
                    }
                    break;
                case WorkType.huiyishenqing:
                    {
                        Msg.Text = "会议申请";
                        workURL = WorkFlowURL.WorkURL("014");
                    }
                    break;
                case WorkType.qingjia:
                    {
                        Msg.Text = "请假";
                        if (String.Compare(((String)Session["station_grade"]), "3") == 0) //基层
                        {
                            workURL = WorkFlowURL.WorkURL("017");
                        }
                        else if (String.Compare(((String)Session["station_grade"]), "2") == 0) //中层
                        {
                            workURL = WorkFlowURL.WorkURL("018");
                        }
                    }
                    break;
                case WorkType.shebeishiyongshenqing:
                    {
                        Msg.Text = "设备使用申请";
                        workURL = WorkFlowURL.WorkURL("013");
                    }
                    break;
                case WorkType.tongzhiyuhuirenyuan:
                    {
                        Msg.Text = "通知与会人员";
                        workURL = WorkFlowURL.WorkURL("016");
                    }
                    break;
            }
            
        }

        //protected void shebeishiyongshenqing_Click(object sender, EventArgs e)
        //{
        //    Session["work_type"] = WorkType.shebeishiyongshenqing;
        //    Server.Transfer("~/NewWork.aspx");
        //}

        //protected void huiyishenqing_Click(object sender, EventArgs e)
        //{
        //    Session["work_type"] = WorkType.huiyishenqing;
        //    Server.Transfer("~/NewWork.aspx");
        //}

        //protected void tongzhiyuhuirenyuan_Click(object sender, EventArgs e)
        //{
        //    Session["work_type"] = WorkType.tongzhiyuhuirenyuan;
        //    Server.Transfer("~/NewWork.aspx");
        //}

        //protected void qingjia_Click(object sender, EventArgs e)
        //{
        //    Session["work_type"] = WorkType.qingjia;
        //    Server.Transfer("~/NewWork.aspx");
        //}

        //protected void gwlzwxsp_Click(object sender, EventArgs e)
        //{
        //    Session["work_type"] = WorkType.gwlzwxsp;
        //    Server.Transfer("~/NewWork.aspx");
        //}

        //protected void gwlzxsp_Click(object sender, EventArgs e)
        //{
        //    Session["work_type"] = WorkType.gwlzxsp;
        //    Server.Transfer("~/NewWork.aspx");
        //}

    }
}